﻿using Sirenix.OdinInspector;
using Sirenix.Utilities;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using YFrameWork.RunTime;


namespace YFrameWork.Editor
{
    [GlobalConfig("Soppurt/YFrameWork/Config/ChangeFontObject")]
    public class ChangeOverview : GlobalConfig<ChangeOverview>
    {
        [ReadOnly]
        public ChangeFontObject mChangeFontObject;


        [ReadOnly]
        public AssetsDataProcedure[] mAssetsDataProcedure;


#if UNITY_EDITOR
        [Button(ButtonSizes.Medium), PropertyOrder(-1)]
        public void UpdateCharacterOverview()
        {
            // Finds and assigns all scriptable objects of type Character
            ChangeFontObject[] AllCharacters = AssetDatabase.FindAssets("t:ChangeFontObject")
                .Select(guid => AssetDatabase.LoadAssetAtPath<ChangeFontObject>(AssetDatabase.GUIDToAssetPath(guid)))
                .ToArray();


            if (AllCharacters.Length > 1)
            {
                Log.Error("当前项目中不止有一个改变字体的数据表");
                return;
            }
            mChangeFontObject = AllCharacters[0];

            mAssetsDataProcedure = AssetDatabase.FindAssets("t:AssetsDataProcedure")
                .Select(guid => AssetDatabase.LoadAssetAtPath<AssetsDataProcedure>(AssetDatabase.GUIDToAssetPath(guid)))
                .ToArray();



        }
#endif
    }
}